<script setup>
// This starter template is using Vue 3 <script setup> SFCs
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
</script>

<template>
<canvas id="myCanvas" width="360" height="650"></canvas>
</template>

<script>
import facecat from './facecat.js';
let gPaint = new facecat.FCPaint();
/*
 * 重置大小
 */
let resizeAll = function () {
	try {
		const canvas = document.getElementById('myCanvas');
		canvas.width = document.documentElement.clientWidth;
		canvas.height = document.documentElement.clientHeight;
		facecat.scaleCanvas(gPaint);
		facecat.updateViewDefault(gPaint.views);
	} catch (err) {
	}
	facecat.invalidate(gPaint);
};
	
export default { 
	data() {
		return {
		}
	},
	onLoad() {
	}, 
	mounted(){
			const canvas = document.getElementById('myCanvas');
			gPaint.isMobile = facecat.isMobileMode();
			window.addEventListener('resize', resizeAll, true);
			let context = canvas.getContext("2d"); //绘图上下文
			canvas.width = window.innerWidth;
			canvas.height = window.innerHeight;
			gPaint.canvas = canvas;
			facecat.scaleCanvas(gPaint);
			//注册事件
			facecat.addDefaultEvent(canvas, gPaint);
			//解析加载XML
			let xml = `<?xml version="1.0" encoding="utf-8"?>
			<html xmlns="facecat">
			  <head>
			  </head>
			  <body>
				<div dock="fill" type="tab" selectedindex="0">
				  <div name="TabPage" text="左右" type="tabpage">
					<div type="splitlayout" layoutstyle="LeftToRight" size="200,200" splitterposition="100,1" name="SplitLayoutDiv" text="SplitLayoutDiv" location="147,250" dock="Fill">
					  <div name="Div" size="200,100" backcolor="rgb(59,174,218)" />
					  <div name="Div2" size="200,100" backcolor="rgb(150,123,220)" />
					</div>
				  </div>
				  <div name="TabPage2" text="右左" type="tabpage">
					<div type="splitlayout" layoutstyle="RightToLeft" size="200,200" splitterposition="100,1" name="SplitLayoutDiv" text="SplitLayoutDiv" location="147,250" dock="Fill">
					  <div name="Div" size="200,100" backcolor="rgb(59,174,218)" />
					  <div name="Div2" size="200,100" backcolor="rgb(150,123,220)" />
					</div>
				  </div>
				  <div name="TabPage3" text="上下" type="tabpage">
					<div type="splitlayout" layoutstyle="TopToBottom" size="200,200" splitterposition="100,1" name="SplitLayoutDiv" text="SplitLayoutDiv" location="147,250" dock="Fill">
					  <div name="Div" size="200,100" backcolor="rgb(59,174,218)" />
					  <div name="Div2" size="200,100" backcolor="rgb(150,123,220)" />
					</div>
				  </div>
				  <div name="TabPage4" text="下上" type="tabpage">
					<div type="splitlayout" layoutstyle="BottomToTop" size="200,200" splitterposition="100,1" name="SplitLayoutDiv" text="SplitLayoutDiv" location="147,250" dock="Fill">
					  <div name="Div" size="200,100" backcolor="rgb(59,174,218)" />
					  <div name="Div2" size="200,100" backcolor="rgb(150,123,220)" />
					</div>
				  </div>
				</div>
			  </body>
			</html>
			`;
			facecat.renderFaceCat(gPaint, xml);	
			},
			methods: {  
	}
}
</script>
